// 腾讯、优酷和爱奇艺跳过广告
var url = window.location.href;
if(new RegExp("v.qq.com").test(url)) {
	window.setInterval(function (){
        let time = document.querySelectorAll(".txp_ad video");
		if(time.length) {
			for(let i = 0; i<time.length; i++){
				time[i].currentTime = 110
			}
		}
    }, 1000);
}else if(new RegExp("v.youku.com").test(url)) {
	var timerTask = window.setInterval(function (){
		//$(".h5-ext-layer").find("div").remove();$(".control-play-icon").click()
		var oDiv = document.querySelectorAll(".h5-ext-layer div");
		if(oDiv && oDiv.length > 0){
			console.log(oDiv.length);
			Array.from(oDiv).forEach(i => i.remove());
			console.log("成功移除元素：.h5-ext-layer div")
			var oIcon = document.getElementsByClassName("control-play-icon");
			if(oIcon && oIcon.length>0) oIcon[0].click();
			console.log("成功点击：.control-play-icon");
			window.clearInterval(timerTask);
		}else{
			console.log(".h5-ext-layer div 尚未加载！！！")
		}
	}, 1000);
} else if(new RegExp("iqiyi.com").test(url)) {
	(function(){
		function callback(){
			var oTime = document.querySelector(".cd-time");
			if(oTime && oTime.innerText > 0) {
				var oDiv = document.querySelector(".skippable-after"); 
				if(oDiv){
					oDiv.click();
					console.log("成功点击 .skippable-after");
					oTime.innerText = 0;
				}
				// tp_vip-time1 //tp_vip-free
				let tpVipTime1 = document.querySelector('.tp_vip-time1');
				if(tpVipTime1.innerText > 0){
					let tpVipFree = document.querySelector('.tp_vip-free');
					tpVipFree.click();
					console.log("成功点击 .tp_vip-free");
					tpVipTime1.innerText = 0;
				}
				// sports-cd-time  sports-vip-text
				let sportsCdTime = document.querySelector('.sports-cd-time');
				if(sportsCdTime.innerText > 0){
					let sportsVipText = document.querySelector('.sports-vip-text');
					sportsVipText.click();
					console.log("成功点击 .sportsVipText");
					sportsCdTime.innerText = 0;
				}
				// tp_close-time tp_close-txt
				let tpCloseTime = document.querySelector('.tp_close-time');
				if(tpCloseTime.innerText > 0){
					let tpCloseTxt = document.querySelector('.tp_close-txt');
					tpCloseTxt.click();
					console.log("成功点击 .tpCloseTxt");
					tpCloseTime.innerText = 0;
				}
			}
		}
		let flashbox = document.getElementById('flashbox');
		let observer = new MutationObserver(callback);
		observer.observe(flashbox, { childList: true, subtree: true });
	})();

	
}